package com.atguigu.blog.comment.controller;

import com.atguigu.blog.comment.entity.Comment;
import com.atguigu.blog.comment.service.CommentService;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;


@RestController
public class CommentController {

    @Autowired
    private CommentService commentService;

    @GetMapping("/comment/article/list")
    public List<Comment> findCommentList(@RequestParam Integer articleId){
        LambdaQueryWrapper<Comment> commentLambdaQueryWrapper = new LambdaQueryWrapper<>();
        commentLambdaQueryWrapper.eq(Comment::getArticleId,articleId);
        List<Comment> list = commentService.list(commentLambdaQueryWrapper);
        return list;
    }
}
